package com.fjec.market.schedule.handler;

import com.fjec.market.service.IBizPhysicalOrderService;
import com.fjec.market.service.IBizSubPhysicalOrderService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component
public class AutoRefundHandler {

    @Resource
    private IBizPhysicalOrderService bizPhysicalOrderService;

    public String handle(int limit, int minutes) {
        List<Map<String, Object>> subOrders = bizPhysicalOrderService.getAutoRefundSubOrders(limit);
        StringBuilder sb = new StringBuilder();
        subOrders.forEach(so -> {
            String log = bizPhysicalOrderService.doAutoRefund(so);
            sb.append(log);
        });

        return sb.toString();
    }
}
